#include "POUS.h"
// FUNCTION
BYTE BITS_BYTE(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7)
{
  BOOL ENO = __BOOL_LITERAL(TRUE);
  BYTE BITS_BYTE = 0;

  // Control execution
  if (!EN) {
    if (__ENO != NULL) {
      *__ENO = __BOOL_LITERAL(FALSE);
    }
    return BITS_BYTE;
  }
  #define GetFbVar(var,...) __GET_VAR(data__->var,__VA_ARGS__)
  #define SetFbVar(var,val,...) __SET_VAR(data__->,var,__VA_ARGS__,val)

    BITS_BYTE|=(BIT0)?1:0;
    BITS_BYTE|=(BIT1)?2:0;
    BITS_BYTE|=(BIT2)?4:0;
    BITS_BYTE|=(BIT3)?8:0;
    BITS_BYTE|=(BIT4)?0x10:0;
    BITS_BYTE|=(BIT5)?0x20:0;
    BITS_BYTE|=(BIT6)?0x40:0;
    BITS_BYTE|=(BIT7)?0x80:0;

  #undef GetFbVar
  #undef SetFbVar
;
  goto __end;

  goto __end;

__end:
  if (__ENO != NULL) {
    *__ENO = ENO;
  }
  return BITS_BYTE;
}


// FUNCTION
WORD BITS_WORD(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL BIT0, 
  BOOL BIT1, 
  BOOL BIT2, 
  BOOL BIT3, 
  BOOL BIT4, 
  BOOL BIT5, 
  BOOL BIT6, 
  BOOL BIT7, 
  BOOL BIT8, 
  BOOL BIT9, 
  BOOL BIT10, 
  BOOL BIT11, 
  BOOL BIT12, 
  BOOL BIT13, 
  BOOL BIT14, 
  BOOL BIT15)
{
  BOOL ENO = __BOOL_LITERAL(TRUE);
  WORD BITS_WORD = 0;

  // Control execution
  if (!EN) {
    if (__ENO != NULL) {
      *__ENO = __BOOL_LITERAL(FALSE);
    }
    return BITS_WORD;
  }
  #define GetFbVar(var,...) __GET_VAR(data__->var,__VA_ARGS__)
  #define SetFbVar(var,val,...) __SET_VAR(data__->,var,__VA_ARGS__,val)

    BITS_WORD|=(BIT0)?1:0;
    BITS_WORD|=(BIT1)?2:0;
    BITS_WORD|=(BIT2)?4:0;
    BITS_WORD|=(BIT3)?8:0;
    BITS_WORD|=(BIT4)?0x10:0;
    BITS_WORD|=(BIT5)?0x20:0;
    BITS_WORD|=(BIT6)?0x40:0;
    BITS_WORD|=(BIT7)?0x80:0;
    BITS_WORD|=(BIT8)?0x100:0;
    BITS_WORD|=(BIT9)?0x200:0;
    BITS_WORD|=(BIT10)?0x400:0;
    BITS_WORD|=(BIT11)?0x800:0;
    BITS_WORD|=(BIT12)?0x1000:0;
    BITS_WORD|=(BIT13)?0x2000:0;
    BITS_WORD|=(BIT14)?0x4000:0;
    BITS_WORD|=(BIT15)?0x8000:0;

  #undef GetFbVar
  #undef SetFbVar
;
  goto __end;

  goto __end;

__end:
  if (__ENO != NULL) {
    *__ENO = ENO;
  }
  return BITS_WORD;
}


// FUNCTION
UDINT TIMESTAMP(
  BOOL EN, 
  BOOL *__ENO, 
  BOOL USERTC)
{
  BOOL ENO = __BOOL_LITERAL(TRUE);
  UDINT TIMESTAMP = 0;

  // Control execution
  if (!EN) {
    if (__ENO != NULL) {
      *__ENO = __BOOL_LITERAL(FALSE);
    }
    return TIMESTAMP;
  }
  #define GetFbVar(var,...) __GET_VAR(data__->var,__VA_ARGS__)
  #define SetFbVar(var,val,...) __SET_VAR(data__->,var,__VA_ARGS__,val)

    TIMESTAMP=plc_rte->timestamp();
    
  #undef GetFbVar
  #undef SetFbVar
;
  goto __end;

  goto __end;

__end:
  if (__ENO != NULL) {
    *__ENO = ENO;
  }
  return TIMESTAMP;
}


void LOGGER_init__(LOGGER *data__, BOOL retain) {
  __INIT_VAR(data__->EN,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ENO,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->TRIG,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->MSG,__STRING_LITERAL(0,""),retain)
  __INIT_VAR(data__->LEVEL,LOGLEVEL__INFO,retain)
  __INIT_VAR(data__->TRIG0,__BOOL_LITERAL(FALSE),retain)
}

// Code part
void LOGGER_body__(LOGGER *data__) {
  // Control execution
  if (!__GET_VAR(data__->EN)) {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(FALSE));
    return;
  }
  else {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(TRUE));
  }
  // Initialise TEMP variables @generate_c.cc L1201

  if ((__GET_VAR(data__->TRIG,) && !(__GET_VAR(data__->TRIG0,)))) {
    #define GetFbVar(var,...) __GET_VAR(data__->var,__VA_ARGS__)
    #define SetFbVar(var,val,...) __SET_VAR(data__->,var,__VA_ARGS__,val)

   LogMessage(GetFbVar(LEVEL),(char*)GetFbVar(MSG, .body),GetFbVar(MSG, .len));
  
    #undef GetFbVar
    #undef SetFbVar
;
  };
  __SET_VAR(data__->,TRIG0,,__GET_VAR(data__->TRIG,));

  goto __end;

__end:
  return;
} // LOGGER_body__() 





void PROC_STATE_init__(PROC_STATE *data__, BOOL retain) {
  __INIT_VAR(data__->EN,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ENO,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ERR_HOME,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ERR_HOME_ID,0,retain)
  __INIT_VAR(data__->ERR_MOVE,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ERR_MOVE_ID,0,retain)
  __INIT_VAR(data__->ERR_MOVE1,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ERR_MOVE2,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOME,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ACT_MOVE,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ACT_MOVE0,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->OUT,0,retain)
}

// Code part
void PROC_STATE_body__(PROC_STATE *data__) {
  // Control execution
  if (!__GET_VAR(data__->EN)) {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(FALSE));
    return;
  }
  else {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(TRUE));
  }
  // Initialise TEMP variables @generate_c.cc L1201

  __SET_VAR(data__->,OUT,,0);
  if (__GET_VAR(data__->HOME,)) {
    __SET_VAR(data__->,OUT,,1);
  };
  if (__GET_VAR(data__->ACT_MOVE,)) {
    __SET_VAR(data__->,OUT,,2);
  };
  if (__GET_VAR(data__->ERR_MOVE,)) {
    __SET_VAR(data__->,OUT,, -(WORD_TO_INT(
      (BOOL)__BOOL_LITERAL(TRUE),
      NULL,
      (WORD)__GET_VAR(data__->ERR_MOVE_ID,))));
  };
  if (__GET_VAR(data__->ERR_HOME,)) {
    __SET_VAR(data__->,OUT,, -(WORD_TO_INT(
      (BOOL)__BOOL_LITERAL(TRUE),
      NULL,
      (WORD)__GET_VAR(data__->ERR_HOME_ID,))));
  };

  goto __end;

__end:
  return;
} // PROC_STATE_body__() 





static inline BOOL __STEPPER_MOVE__BOOL__BOOL1(BOOL EN,
  BOOL IN,
  STEPPER *data__)
{
  BOOL __res;
  BOOL __TMP_ENO = __GET_VAR(data__->_TMP_MOVE138_ENO,);
  __res = MOVE__BOOL__BOOL(EN,
    &__TMP_ENO,
    IN);
  __SET_VAR(,data__->_TMP_MOVE138_ENO,,__TMP_ENO);
  return __res;
}

void STEPPER_init__(STEPPER *data__, BOOL retain) {
  __INIT_VAR(data__->EN,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ENO,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->AXIS,-1,retain)
  __INIT_VAR(data__->POS,0,retain)
  __INIT_VAR(data__->STATE,0,retain)
  __INIT_VAR(data__->TARGET,0,retain)
  __INIT_VAR(data__->RUN,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->RUNING,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->SPEED,0,retain)
  __INIT_VAR(data__->ASPEED,0,retain)
  __INIT_VAR(data__->HOME,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOMESPEED,0,retain)
  __INIT_VAR(data__->HOMELOOKUP,0,retain)
  __INIT_VAR(data__->XIFEN,0,retain)
  __INIT_VAR(data__->RUN_DIR,MC_DIRECTION__MCABSOLUTEPOSITION,retain)
  __INIT_VAR(data__->HOMEMODE,MC_HOMING_PROCEDURES__MCHOMEDIRECT,retain)
  __INIT_VAR(data__->BUFFMODE,MC_BUFFER_MODE__MCABORTING,retain)
  __INIT_VAR(data__->MC_SETPOSMODE,MC_EXECUTION_MODE__MCIMMEDIATELY,retain)
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER8,retain);
  MC_HOME_init__(&data__->MC_HOME1,retain);
  MC_MOVEABSOLUTE_init__(&data__->MC_MOVEABSOLUTE3,retain);
  MC_POWER_init__(&data__->MC_POWER3,retain);
  MC_READACTUALPOSITION_init__(&data__->MC_READACTUALPOSITION3,retain);
  PROC_STATE_init__(&data__->PROC_STATE3,retain);
  MC_SETPOSITION_init__(&data__->MC_SETPOSITION3,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER0,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER6,retain);
  __INIT_VAR(data__->_TMP_MOVE138_ENO,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->_TMP_MOVE138_OUT,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->_TMP_OR222_OUT,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->_TMP_DIV167_OUT,0,retain)
}

// Code part
void STEPPER_body__(STEPPER *data__) {
  // Control execution
  if (!__GET_VAR(data__->EN)) {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(FALSE));
    return;
  }
  else {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(TRUE));
  }
  // Initialise TEMP variables @generate_c.cc L1201

  __SET_VAR(data__->MC_READACTUALPOSITION3.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_READACTUALPOSITION3.,ENABLE,,__GET_VAR(data__->MC_POWER3.STATUS,));
  MC_READACTUALPOSITION_body__(&data__->MC_READACTUALPOSITION3);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_READACTUALPOSITION3.AXIS));
  __SET_VAR(data__->,POS,,__GET_VAR(data__->MC_READACTUALPOSITION3.POSITION,));
  __SET_VAR(data__->,_TMP_MOVE138_OUT,,__STEPPER_MOVE__BOOL__BOOL1(
    (BOOL)__GET_VAR(data__->MC_MOVEABSOLUTE3.DONE,),
    (BOOL)0,
    data__));
  if (__GET_VAR(data__->_TMP_MOVE138_ENO,)) {
    __SET_VAR(data__->,RUN,,__GET_VAR(data__->_TMP_MOVE138_OUT,));
  };
  __SET_VAR(data__->PROC_STATE3.,ERR_HOME,,__GET_VAR(data__->MC_HOME1.ERROR,));
  __SET_VAR(data__->PROC_STATE3.,ERR_HOME_ID,,__GET_VAR(data__->MC_HOME1.ERRORID,));
  __SET_VAR(data__->PROC_STATE3.,ERR_MOVE,,__GET_VAR(data__->MC_MOVEABSOLUTE3.ERROR,));
  __SET_VAR(data__->PROC_STATE3.,HOME,,__GET_VAR(data__->MC_HOME1.ACTIVE,));
  __SET_VAR(data__->PROC_STATE3.,ACT_MOVE,,__GET_VAR(data__->MC_MOVEABSOLUTE3.ACTIVE,));
  PROC_STATE_body__(&data__->PROC_STATE3);
  __SET_VAR(data__->,STATE,,__GET_VAR(data__->PROC_STATE3.OUT,));
  __SET_VAR(data__->,_TMP_OR222_OUT,,OR__BOOL__BOOL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (UINT)2,
    (BOOL)__GET_VAR(data__->MC_MOVEABSOLUTE3.BUSY,),
    (BOOL)__GET_VAR(data__->MC_HOME1.BUSY,)));
  __SET_VAR(data__->,RUNING,,__GET_VAR(data__->_TMP_OR222_OUT,));
  __SET_VAR(data__->MC_POWER3.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_POWER3.,ENABLE,,1);
  __SET_VAR(data__->MC_POWER3.,ENABLEPOSITIVE,,1);
  __SET_VAR(data__->MC_POWER3.,ENABLENEGATIVE,,1);
  MC_POWER_body__(&data__->MC_POWER3);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_POWER3.AXIS));
  __SET_VAR(data__->MC_HOME1.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_HOME1.,EXECUTE,,__GET_VAR(data__->MC_WRITEPARAMETER0.DONE,));
  __SET_VAR(data__->MC_HOME1.,HOMINGMODE,,__GET_VAR(data__->HOMEMODE,));
  __SET_VAR(data__->MC_HOME1.,BUFFERMODE,,__GET_VAR(data__->BUFFMODE,));
  MC_HOME_body__(&data__->MC_HOME1);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_HOME1.AXIS));
  __SET_VAR(data__->MC_SETPOSITION3.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_SETPOSITION3.,EXECUTE,,__GET_VAR(data__->MC_HOME1.DONE,));
  __SET_VAR(data__->MC_SETPOSITION3.,POSITION,,0.0);
  __SET_VAR(data__->MC_SETPOSITION3.,EXECUTIONMODE,,__GET_VAR(data__->MC_SETPOSMODE,));
  MC_SETPOSITION_body__(&data__->MC_SETPOSITION3);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_SETPOSITION3.AXIS));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,EXECUTE,,__GET_VAR(data__->RUN,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,CONTINUOUSUPDATE,,1);
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,POSITION,,__GET_VAR(data__->TARGET,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,VELOCITY,,__GET_VAR(data__->SPEED,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,ACCELERATION,,__GET_VAR(data__->_TMP_DIV167_OUT,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,DECELERATION,,__GET_VAR(data__->_TMP_DIV167_OUT,));
  __SET_VAR(data__->MC_MOVEABSOLUTE3.,DIRECTION,,__GET_VAR(data__->RUN_DIR,));
  MC_MOVEABSOLUTE_body__(&data__->MC_MOVEABSOLUTE3);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_MOVEABSOLUTE3.AXIS));
  __SET_VAR(data__->,_TMP_DIV167_OUT,,DIV__REAL__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->SPEED,),
    (REAL)__GET_VAR(data__->ASPEED,)));
  __SET_VAR(data__->MC_WRITEPARAMETER8.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_WRITEPARAMETER8.,EXECUTE,,__GET_VAR(data__->HOME,));
  __SET_VAR(data__->MC_WRITEPARAMETER8.,PARAMETERNUMBER,,1018);
  __SET_VAR(data__->MC_WRITEPARAMETER8.,VALUE,,__GET_VAR(data__->HOMELOOKUP,));
  MC_WRITEPARAMETER_body__(&data__->MC_WRITEPARAMETER8);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_WRITEPARAMETER8.AXIS));
  __SET_VAR(data__->MC_WRITEPARAMETER0.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_WRITEPARAMETER0.,EXECUTE,,__GET_VAR(data__->MC_WRITEPARAMETER8.DONE,));
  __SET_VAR(data__->MC_WRITEPARAMETER0.,PARAMETERNUMBER,,1010);
  __SET_VAR(data__->MC_WRITEPARAMETER0.,VALUE,,__GET_VAR(data__->HOMESPEED,));
  MC_WRITEPARAMETER_body__(&data__->MC_WRITEPARAMETER0);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_WRITEPARAMETER0.AXIS));
  __SET_VAR(data__->MC_WRITEPARAMETER6.,AXIS,,__GET_VAR(data__->AXIS,));
  __SET_VAR(data__->MC_WRITEPARAMETER6.,EXECUTE,,__GET_VAR(data__->MC_POWER3.STATUS,));
  __SET_VAR(data__->MC_WRITEPARAMETER6.,PARAMETERNUMBER,,1003);
  __SET_VAR(data__->MC_WRITEPARAMETER6.,VALUE,,__GET_VAR(data__->XIFEN,));
  MC_WRITEPARAMETER_body__(&data__->MC_WRITEPARAMETER6);
  __SET_VAR(data__->,AXIS,,__GET_VAR(data__->MC_WRITEPARAMETER6.AXIS));

  goto __end;

__end:
  return;
} // STEPPER_body__() 





void WK_HYP_init__(WK_HYP *data__, BOOL retain) {
  __INIT_VAR(data__->EN,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ENO,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->H,0,retain)
  __INIT_VAR(data__->CV,0,retain)
  __INIT_VAR(data__->L,0,retain)
  __INIT_VAR(data__->OUT,0,retain)
  __INIT_VAR(data__->OUT0,0,retain)
  __INIT_VAR(data__->COUNT,0,retain)
}

// Code part
void WK_HYP_body__(WK_HYP *data__) {
  // Control execution
  if (!__GET_VAR(data__->EN)) {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(FALSE));
    return;
  }
  else {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(TRUE));
  }
  // Initialise TEMP variables @generate_c.cc L1201

  if (((__GET_VAR(data__->CV,) >= __GET_VAR(data__->H,)) && (__GET_VAR(data__->COUNT,) > 50))) {
    __SET_VAR(data__->,OUT0,,0);
    __SET_VAR(data__->,COUNT,,0);
  };
  if (((__GET_VAR(data__->CV,) < __GET_VAR(data__->L,)) && (__GET_VAR(data__->COUNT,) > 50))) {
    __SET_VAR(data__->,OUT0,,100);
    __SET_VAR(data__->,COUNT,,0);
  };
  __SET_VAR(data__->,OUT,,__GET_VAR(data__->OUT0,));
  __SET_VAR(data__->,COUNT,,(__GET_VAR(data__->COUNT,) + 1));

  goto __end;

__end:
  return;
} // WK_HYP_body__() 





void WK_PID_init__(WK_PID *data__, BOOL retain) {
  __INIT_VAR(data__->EN,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->ENO,__BOOL_LITERAL(TRUE),retain)
  __INIT_VAR(data__->SV,0,retain)
  __INIT_VAR(data__->CV,0,retain)
  __INIT_VAR(data__->RANGER,0,retain)
  __INIT_VAR(data__->KP,0,retain)
  __INIT_VAR(data__->KI,0,retain)
  __INIT_VAR(data__->KD,0,retain)
  __INIT_VAR(data__->OUT,0,retain)
  __INIT_VAR(data__->PIDING,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->ERROR,0,retain)
  __INIT_VAR(data__->SUMERROR,0,retain)
  __INIT_VAR(data__->DERROR,0,retain)
  __INIT_VAR(data__->PERROR,0,retain)
  __INIT_VAR(data__->LERROR,0,retain)
}

// Code part
void WK_PID_body__(WK_PID *data__) {
  // Control execution
  if (!__GET_VAR(data__->EN)) {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(FALSE));
    return;
  }
  else {
    __SET_VAR(data__->,ENO,,__BOOL_LITERAL(TRUE));
  }
  // Initialise TEMP variables @generate_c.cc L1201

  __SET_VAR(data__->,ERROR,,(__GET_VAR(data__->SV,) - __GET_VAR(data__->CV,)));
  if (((__GET_VAR(data__->OUT,) > 0.0) && (__GET_VAR(data__->OUT,) < 100.0))) {
    __SET_VAR(data__->,SUMERROR,,(__GET_VAR(data__->SUMERROR,) + __GET_VAR(data__->ERROR,)));
  };
  __SET_VAR(data__->,DERROR,,(__GET_VAR(data__->LERROR,) - __GET_VAR(data__->PERROR,)));
  __SET_VAR(data__->,PERROR,,__GET_VAR(data__->LERROR,));
  __SET_VAR(data__->,LERROR,,__GET_VAR(data__->ERROR,));
  __SET_VAR(data__->,OUT,,(((__GET_VAR(data__->KP,) * __GET_VAR(data__->ERROR,)) + (__GET_VAR(data__->SUMERROR,) * __GET_VAR(data__->KI,))) + (__GET_VAR(data__->DERROR,) * __GET_VAR(data__->KD,))));
  if ((__GET_VAR(data__->OUT,) > 100.0)) {
    __SET_VAR(data__->,OUT,,100.0);
  } else {
    if ((__GET_VAR(data__->OUT,) < 0.0)) {
      __SET_VAR(data__->,OUT,,0.0);
    };
  };
  if ((__GET_VAR(data__->CV,) > (__GET_VAR(data__->SV,) + __GET_VAR(data__->RANGER,)))) {
    __SET_VAR(data__->,OUT,,0.0);
  } else {
    if ((__GET_VAR(data__->CV,) < (__GET_VAR(data__->SV,) - __GET_VAR(data__->RANGER,)))) {
      __SET_VAR(data__->,OUT,,100.0);
    };
  };

  goto __end;

__end:
  return;
} // WK_PID_body__() 





void PROGRAM0_init__(PROGRAM0 *data__, BOOL retain) {
  __INIT_VAR(data__->RESET_ALL,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->GOHOME,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->WKON1,0,retain)
  __INIT_VAR(data__->WKON2,0,retain)
  __INIT_VAR(data__->WKON3,0,retain)
  __INIT_VAR(data__->WKON4,0,retain)
  __INIT_VAR(data__->WKSET1,20.0,1)
  __INIT_VAR(data__->WKSET2,20.0,1)
  __INIT_VAR(data__->WKSET3,20.0,1)
  __INIT_VAR(data__->WKSET4,20.0,1)
  __INIT_VAR(data__->WKSET_L,5.0,retain)
  __INIT_VAR(data__->TEMP1,0,retain)
  __INIT_VAR(data__->TEMP2,0,retain)
  __INIT_VAR(data__->TEMP3,0,retain)
  __INIT_VAR(data__->TEMP4,0,retain)
  __INIT_VAR(data__->JIAOZHUN1,0.0,1)
  __INIT_VAR(data__->JIAOZHUN2,0.0,1)
  __INIT_VAR(data__->JIAOZHUN3,0.0,1)
  __INIT_VAR(data__->JIAOZHUN4,0.0,1)
  __INIT_LOCATED(REAL,__ID1_12_0,data__->TEMP_IN1,retain)
  __INIT_LOCATED_VALUE(data__->TEMP_IN1,0)
  __INIT_LOCATED(REAL,__ID1_12_1,data__->TEMP_IN2,retain)
  __INIT_LOCATED_VALUE(data__->TEMP_IN2,0)
  __INIT_LOCATED(REAL,__ID1_12_2,data__->TEMP_IN3,retain)
  __INIT_LOCATED_VALUE(data__->TEMP_IN3,0)
  __INIT_LOCATED(REAL,__ID1_12_3,data__->TEMP_IN4,retain)
  __INIT_LOCATED_VALUE(data__->TEMP_IN4,0)
  __INIT_LOCATED(BOOL,__IX1_10_5,data__->LOCALVAR14,retain)
  __INIT_LOCATED_VALUE(data__->LOCALVAR14,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_6,data__->LOCALVAR15,retain)
  __INIT_LOCATED_VALUE(data__->LOCALVAR15,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_7,data__->LOCALVAR16,retain)
  __INIT_LOCATED_VALUE(data__->LOCALVAR16,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_8,data__->LOCALVAR17,retain)
  __INIT_LOCATED_VALUE(data__->LOCALVAR17,__BOOL_LITERAL(FALSE))
  __INIT_VAR(data__->SPEED1,1.0,retain)
  __INIT_VAR(data__->ASPEED1,0.5,retain)
  __INIT_VAR(data__->SPEED2,1.0,retain)
  __INIT_VAR(data__->ASPEED2,0.5,retain)
  __INIT_VAR(data__->SPEED3,1.0,retain)
  __INIT_VAR(data__->ASPEED3,0.5,retain)
  __INIT_VAR(data__->SPEED4,1.0,retain)
  __INIT_VAR(data__->ASPEED4,0.5,retain)
  __INIT_VAR(data__->TARGET1,10.0,retain)
  __INIT_VAR(data__->POS1,0.0,retain)
  __INIT_VAR(data__->TARGET2,10.0,retain)
  __INIT_VAR(data__->POS2,20.0,retain)
  __INIT_VAR(data__->TARGET3,10.0,retain)
  __INIT_VAR(data__->POS3,30.0,retain)
  __INIT_VAR(data__->TARGET4,10.0,retain)
  __INIT_VAR(data__->POS4,30.0,retain)
  __INIT_VAR(data__->STATUS1,-1,retain)
  __INIT_VAR(data__->STATUS2,-2,retain)
  __INIT_VAR(data__->STATUS3,-3,retain)
  __INIT_VAR(data__->STATUS4,-4,retain)
  __INIT_VAR(data__->RUN1,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->RUN2,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->RUN3,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->RUN4,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOMESPEED1,2.0,1)
  __INIT_VAR(data__->HOMESPEED2,2.0,1)
  __INIT_VAR(data__->HOMESPEED3,2.0,1)
  __INIT_VAR(data__->HOMESPEED4,2.0,1)
  __INIT_VAR(data__->HOMESPEEDZERO1,0.2,1)
  __INIT_VAR(data__->HOMESPEEDZERO2,0.2,1)
  __INIT_VAR(data__->HOMESPEEDZERO3,0.2,1)
  __INIT_VAR(data__->HOMESPEEDZERO4,0.2,1)
  __INIT_VAR(data__->HOME1,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOME2,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOME3,__BOOL_LITERAL(FALSE),retain)
  __INIT_VAR(data__->HOME4,__BOOL_LITERAL(FALSE),retain)
  __INIT_LOCATED(BOOL,__QX1_10_25,data__->DCMOTOR_RUN,retain)
  __INIT_LOCATED_VALUE(data__->DCMOTOR_RUN,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__QX1_10_26,data__->DCMOTOR_DIR,retain)
  __INIT_LOCATED_VALUE(data__->DCMOTOR_DIR,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(UINT,__QW1_11_16,data__->DCMOTOR_SPEED_SET,retain)
  __INIT_LOCATED_VALUE(data__->DCMOTOR_SPEED_SET,0)
  __INIT_LOCATED(UINT,__IW1_11_14,data__->DCMOTOR_SPEED,retain)
  __INIT_LOCATED_VALUE(data__->DCMOTOR_SPEED,0)
  __INIT_LOCATED(UINT,__QW1_11_15,data__->DCMOTOR_FREQ,1)
  __INIT_LOCATED_VALUE(data__->DCMOTOR_FREQ,20000)
  __INIT_LOCATED(INT,__QW1_11_17,data__->DC_MOTOR2_SPEED,retain)
  __INIT_LOCATED_VALUE(data__->DC_MOTOR2_SPEED,0)
  __INIT_LOCATED(BOOL,__QX1_10_16,data__->J1,retain)
  __INIT_LOCATED_VALUE(data__->J1,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__QX1_10_17,data__->J2,retain)
  __INIT_LOCATED_VALUE(data__->J2,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__QX1_10_18,data__->J3,retain)
  __INIT_LOCATED_VALUE(data__->J3,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__QX1_10_19,data__->J4,retain)
  __INIT_LOCATED_VALUE(data__->J4,__BOOL_LITERAL(FALSE))
  __INIT_VAR(data__->RUN_EN,1,retain)
  __INIT_VAR(data__->TEMPUSE1,1,retain)
  MC_HOME_init__(&data__->MC_HOME0,retain);
  __INIT_VAR(data__->AXIS_0,0,retain)
  __INIT_VAR(data__->AXIS_1,1,retain)
  __INIT_VAR(data__->AXIS_2,2,retain)
  __INIT_VAR(data__->AXIS_3,3,retain)
  __INIT_VAR(data__->MC_CAMTABLESELECT1,-1,retain)
  WK_PID_init__(&data__->WK_PID0,retain);
  __INIT_VAR(data__->KP,0.1,1)
  __INIT_VAR(data__->KI,0.001,1)
  __INIT_VAR(data__->KD,0.0,1)
  __INIT_LOCATED(UINT,__QW1_11_4,data__->PWM1,retain)
  __INIT_LOCATED_VALUE(data__->PWM1,0)
  __INIT_LOCATED(UINT,__QW1_11_5,data__->PWM2,retain)
  __INIT_LOCATED_VALUE(data__->PWM2,0)
  __INIT_LOCATED(UINT,__QW1_11_6,data__->PWM3,retain)
  __INIT_LOCATED_VALUE(data__->PWM3,0)
  __INIT_LOCATED(UINT,__QW1_11_7,data__->PWM4,retain)
  __INIT_LOCATED_VALUE(data__->PWM4,0)
  __INIT_VAR(data__->XIFEN1,2560.0,retain)
  __INIT_VAR(data__->XIFEN2,200.0,retain)
  __INIT_VAR(data__->XIFEN3,200.0,retain)
  __INIT_VAR(data__->XIFEN4,200.0,retain)
  MC_MOVEABSOLUTE_init__(&data__->MC_MOVEABSOLUTE0,retain);
  MC_POWER_init__(&data__->MC_POWER0,retain);
  __INIT_VAR(data__->HOME_P,MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHPOSITIVE,retain)
  __INIT_VAR(data__->HOME_N,MC_HOMING_PROCEDURES__MCHOMEABSOLUTESWITCHNEGATIVE,retain)
  __INIT_VAR(data__->DIR_P,MC_DIRECTION__MCPOSITIVEDIRECTION,retain)
  __INIT_VAR(data__->DIR_N,MC_DIRECTION__MCSHORTESTWAY,retain)
  __INIT_VAR(data__->BUFFMODE,MC_BUFFER_MODE__MCABORTING,retain)
  __INIT_LOCATED(BOOL,__IX1_10_1,data__->X1,retain)
  __INIT_LOCATED_VALUE(data__->X1,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_2,data__->X2,retain)
  __INIT_LOCATED_VALUE(data__->X2,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_3,data__->X3,retain)
  __INIT_LOCATED_VALUE(data__->X3,__BOOL_LITERAL(FALSE))
  __INIT_LOCATED(BOOL,__IX1_10_4,data__->X4,retain)
  __INIT_LOCATED_VALUE(data__->X4,__BOOL_LITERAL(FALSE))
  MC_READACTUALPOSITION_init__(&data__->MC_READACTUALPOSITION0,retain);
  PROC_STATE_init__(&data__->PROC_STATE0,retain);
  MC_SETPOSITION_init__(&data__->MC_SETPOSITION0,retain);
  __INIT_VAR(data__->MC_SETPOSMODE,MC_EXECUTION_MODE__MCIMMEDIATELY,retain)
  MC_HOME_init__(&data__->MC_HOME2,retain);
  MC_MOVEABSOLUTE_init__(&data__->MC_MOVEABSOLUTE1,retain);
  MC_POWER_init__(&data__->MC_POWER1,retain);
  MC_READACTUALPOSITION_init__(&data__->MC_READACTUALPOSITION1,retain);
  PROC_STATE_init__(&data__->PROC_STATE1,retain);
  MC_SETPOSITION_init__(&data__->MC_SETPOSITION1,retain);
  MC_HOME_init__(&data__->MC_HOME3,retain);
  MC_MOVEABSOLUTE_init__(&data__->MC_MOVEABSOLUTE2,retain);
  MC_POWER_init__(&data__->MC_POWER2,retain);
  MC_READACTUALPOSITION_init__(&data__->MC_READACTUALPOSITION2,retain);
  PROC_STATE_init__(&data__->PROC_STATE2,retain);
  MC_SETPOSITION_init__(&data__->MC_SETPOSITION2,retain);
  WK_PID_init__(&data__->WK_PID1,retain);
  WK_PID_init__(&data__->WK_PID2,retain);
  WK_PID_init__(&data__->WK_PID3,retain);
  MC_HOME_init__(&data__->MC_HOME1,retain);
  MC_MOVEABSOLUTE_init__(&data__->MC_MOVEABSOLUTE3,retain);
  MC_POWER_init__(&data__->MC_POWER3,retain);
  MC_READACTUALPOSITION_init__(&data__->MC_READACTUALPOSITION3,retain);
  PROC_STATE_init__(&data__->PROC_STATE3,retain);
  MC_SETPOSITION_init__(&data__->MC_SETPOSITION3,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER0,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER1,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER2,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER3,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER4,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER5,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER6,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER7,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER8,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER9,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER10,retain);
  MC_WRITEPARAMETER_init__(&data__->MC_WRITEPARAMETER11,retain);
  WK_HYP_init__(&data__->WK_HYP1,retain);
  WK_HYP_init__(&data__->WK_HYP2,retain);
  WK_HYP_init__(&data__->WK_HYP4,retain);
  WK_HYP_init__(&data__->WK_HYP0,retain);
  STEPPER_init__(&data__->STEPPER3,retain);
  STEPPER_init__(&data__->STEPPER0,retain);
  STEPPER_init__(&data__->STEPPER1,retain);
  STEPPER_init__(&data__->STEPPER2,retain);
  __INIT_VAR(data__->_TMP_ADD221_OUT,0,retain)
  __INIT_VAR(data__->_TMP_ADD103_OUT,0,retain)
  __INIT_VAR(data__->_TMP_ADD223_OUT,0,retain)
  __INIT_VAR(data__->_TMP_ADD227_OUT,0,retain)
  __INIT_VAR(data__->_TMP_REAL_TO_UINT31_OUT,0,retain)
  __INIT_VAR(data__->_TMP_REAL_TO_UINT25_OUT,0,retain)
  __INIT_VAR(data__->_TMP_REAL_TO_UINT63_OUT,0,retain)
  __INIT_VAR(data__->_TMP_REAL_TO_UINT96_OUT,0,retain)
  __INIT_VAR(data__->_TMP_SUB200_OUT,0,retain)
  __INIT_VAR(data__->_TMP_SUB185_OUT,0,retain)
  __INIT_VAR(data__->_TMP_SUB215_OUT,0,retain)
  __INIT_VAR(data__->_TMP_SUB177_OUT,0,retain)
}

// Code part
void PROGRAM0_body__(PROGRAM0 *data__) {
  // Initialise TEMP variables in generate_c.cc L1389

  __SET_VAR(data__->,_TMP_ADD221_OUT,,ADD__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (UINT)2,
    (REAL)__GET_LOCATED(data__->TEMP_IN1,),
    (REAL)__GET_VAR(data__->JIAOZHUN1,)));
  __SET_VAR(data__->,TEMP1,,__GET_VAR(data__->_TMP_ADD221_OUT,));
  __SET_VAR(data__->,_TMP_ADD103_OUT,,ADD__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (UINT)2,
    (REAL)__GET_LOCATED(data__->TEMP_IN2,),
    (REAL)__GET_VAR(data__->JIAOZHUN2,)));
  __SET_VAR(data__->,TEMP2,,__GET_VAR(data__->_TMP_ADD103_OUT,));
  __SET_VAR(data__->,_TMP_ADD223_OUT,,ADD__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (UINT)2,
    (REAL)__GET_LOCATED(data__->TEMP_IN3,),
    (REAL)__GET_VAR(data__->JIAOZHUN3,)));
  __SET_VAR(data__->,TEMP3,,__GET_VAR(data__->_TMP_ADD223_OUT,));
  __SET_VAR(data__->,_TMP_ADD227_OUT,,ADD__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (UINT)2,
    (REAL)__GET_LOCATED(data__->TEMP_IN4,),
    (REAL)__GET_VAR(data__->JIAOZHUN4,)));
  __SET_VAR(data__->,TEMP4,,__GET_VAR(data__->_TMP_ADD227_OUT,));
  __SET_VAR(data__->STEPPER1.,AXIS,,__GET_VAR(data__->AXIS_1,));
  __SET_VAR(data__->STEPPER1.,TARGET,,__GET_VAR(data__->TARGET2,));
  __SET_VAR(data__->STEPPER1.,RUN,,__GET_VAR(data__->RUN2,));
  __SET_VAR(data__->STEPPER1.,SPEED,,__GET_VAR(data__->SPEED2,));
  __SET_VAR(data__->STEPPER1.,ASPEED,,__GET_VAR(data__->ASPEED2,));
  __SET_VAR(data__->STEPPER1.,HOME,,__GET_VAR(data__->HOME2,));
  __SET_VAR(data__->STEPPER1.,HOMESPEED,,__GET_VAR(data__->HOMESPEED2,));
  __SET_VAR(data__->STEPPER1.,HOMELOOKUP,,__GET_VAR(data__->HOMESPEEDZERO2,));
  __SET_VAR(data__->STEPPER1.,XIFEN,,__GET_VAR(data__->XIFEN2,));
  __SET_VAR(data__->STEPPER1.,RUN_DIR,,__GET_VAR(data__->DIR_P,));
  __SET_VAR(data__->STEPPER1.,HOMEMODE,,__GET_VAR(data__->HOME_P,));
  STEPPER_body__(&data__->STEPPER1);
  __SET_VAR(data__->,RUN2,,__GET_VAR(data__->STEPPER1.RUN));
  __SET_VAR(data__->,HOME2,,__GET_VAR(data__->STEPPER1.HOME));
  __SET_VAR(data__->,POS2,,__GET_VAR(data__->STEPPER1.POS,));
  __SET_VAR(data__->STEPPER0.,AXIS,,__GET_VAR(data__->AXIS_0,));
  __SET_VAR(data__->STEPPER0.,TARGET,,__GET_VAR(data__->TARGET1,));
  __SET_VAR(data__->STEPPER0.,RUN,,__GET_VAR(data__->RUN1,));
  __SET_VAR(data__->STEPPER0.,SPEED,,__GET_VAR(data__->SPEED1,));
  __SET_VAR(data__->STEPPER0.,ASPEED,,__GET_VAR(data__->ASPEED1,));
  __SET_VAR(data__->STEPPER0.,HOME,,__GET_VAR(data__->HOME1,));
  __SET_VAR(data__->STEPPER0.,HOMESPEED,,__GET_VAR(data__->HOMESPEED1,));
  __SET_VAR(data__->STEPPER0.,HOMELOOKUP,,__GET_VAR(data__->HOMESPEEDZERO1,));
  __SET_VAR(data__->STEPPER0.,XIFEN,,__GET_VAR(data__->XIFEN1,));
  __SET_VAR(data__->STEPPER0.,RUN_DIR,,__GET_VAR(data__->DIR_P,));
  __SET_VAR(data__->STEPPER0.,HOMEMODE,,__GET_VAR(data__->HOME_P,));
  STEPPER_body__(&data__->STEPPER0);
  __SET_VAR(data__->,RUN1,,__GET_VAR(data__->STEPPER0.RUN));
  __SET_VAR(data__->,HOME1,,__GET_VAR(data__->STEPPER0.HOME));
  __SET_VAR(data__->,POS1,,__GET_VAR(data__->STEPPER0.POS,));
  __SET_VAR(data__->,STATUS2,,__GET_VAR(data__->STEPPER1.STATE,));
  __SET_VAR(data__->,STATUS1,,__GET_VAR(data__->STEPPER0.STATE,));
  __SET_VAR(data__->,HOME2,,__GET_VAR(data__->STEPPER1.HOME,));
  __SET_VAR(data__->,HOME1,,__GET_VAR(data__->STEPPER0.HOME,));
  __SET_VAR(data__->STEPPER2.,AXIS,,__GET_VAR(data__->AXIS_2,));
  __SET_VAR(data__->STEPPER2.,TARGET,,__GET_VAR(data__->TARGET3,));
  __SET_VAR(data__->STEPPER2.,RUN,,__GET_VAR(data__->RUN3,));
  __SET_VAR(data__->STEPPER2.,SPEED,,__GET_VAR(data__->SPEED3,));
  __SET_VAR(data__->STEPPER2.,ASPEED,,__GET_VAR(data__->ASPEED3,));
  __SET_VAR(data__->STEPPER2.,HOME,,__GET_VAR(data__->HOME3,));
  __SET_VAR(data__->STEPPER2.,HOMESPEED,,__GET_VAR(data__->HOMESPEED3,));
  __SET_VAR(data__->STEPPER2.,HOMELOOKUP,,__GET_VAR(data__->HOMESPEEDZERO3,));
  __SET_VAR(data__->STEPPER2.,XIFEN,,__GET_VAR(data__->XIFEN3,));
  __SET_VAR(data__->STEPPER2.,RUN_DIR,,__GET_VAR(data__->DIR_P,));
  __SET_VAR(data__->STEPPER2.,HOMEMODE,,__GET_VAR(data__->HOME_P,));
  STEPPER_body__(&data__->STEPPER2);
  __SET_VAR(data__->,RUN3,,__GET_VAR(data__->STEPPER2.RUN));
  __SET_VAR(data__->,HOME3,,__GET_VAR(data__->STEPPER2.HOME));
  __SET_VAR(data__->,POS3,,__GET_VAR(data__->STEPPER2.POS,));
  __SET_VAR(data__->STEPPER3.,AXIS,,__GET_VAR(data__->AXIS_3,));
  __SET_VAR(data__->STEPPER3.,TARGET,,__GET_VAR(data__->TARGET4,));
  __SET_VAR(data__->STEPPER3.,RUN,,__GET_VAR(data__->RUN4,));
  __SET_VAR(data__->STEPPER3.,SPEED,,__GET_VAR(data__->SPEED4,));
  __SET_VAR(data__->STEPPER3.,ASPEED,,__GET_VAR(data__->ASPEED4,));
  __SET_VAR(data__->STEPPER3.,HOME,,__GET_VAR(data__->HOME4,));
  __SET_VAR(data__->STEPPER3.,HOMESPEED,,__GET_VAR(data__->HOMESPEED4,));
  __SET_VAR(data__->STEPPER3.,HOMELOOKUP,,__GET_VAR(data__->HOMESPEEDZERO4,));
  __SET_VAR(data__->STEPPER3.,XIFEN,,__GET_VAR(data__->XIFEN4,));
  __SET_VAR(data__->STEPPER3.,RUN_DIR,,__GET_VAR(data__->DIR_P,));
  __SET_VAR(data__->STEPPER3.,HOMEMODE,,__GET_VAR(data__->HOME_P,));
  STEPPER_body__(&data__->STEPPER3);
  __SET_VAR(data__->,RUN4,,__GET_VAR(data__->STEPPER3.RUN));
  __SET_VAR(data__->,HOME4,,__GET_VAR(data__->STEPPER3.HOME));
  __SET_VAR(data__->,POS4,,__GET_VAR(data__->STEPPER3.POS,));
  __SET_VAR(data__->,STATUS3,,__GET_VAR(data__->STEPPER2.STATE,));
  __SET_VAR(data__->,STATUS4,,__GET_VAR(data__->STEPPER3.STATE,));
  __SET_VAR(data__->,HOME3,,__GET_VAR(data__->STEPPER2.HOME,));
  __SET_VAR(data__->,HOME4,,__GET_VAR(data__->STEPPER3.HOME,));
  __SET_VAR(data__->WK_HYP2.,EN,,__GET_VAR(data__->WKON4,));
  __SET_VAR(data__->WK_HYP2.,H,,__GET_VAR(data__->WKSET4,));
  __SET_VAR(data__->WK_HYP2.,CV,,__GET_VAR(data__->TEMP4,));
  __SET_VAR(data__->WK_HYP2.,L,,__GET_VAR(data__->_TMP_SUB200_OUT,));
  WK_HYP_body__(&data__->WK_HYP2);
  if (__GET_VAR(data__->WK_HYP2.ENO,)) {
    __SET_LOCATED(data__->,PWM4,,__GET_VAR(data__->WK_HYP2.OUT,));
  };
  __SET_VAR(data__->WK_HYP0.,EN,,__GET_VAR(data__->WKON2,));
  __SET_VAR(data__->WK_HYP0.,H,,__GET_VAR(data__->WKSET2,));
  __SET_VAR(data__->WK_HYP0.,CV,,__GET_VAR(data__->TEMP2,));
  __SET_VAR(data__->WK_HYP0.,L,,__GET_VAR(data__->_TMP_SUB177_OUT,));
  WK_HYP_body__(&data__->WK_HYP0);
  if (__GET_VAR(data__->WK_HYP0.ENO,)) {
    __SET_LOCATED(data__->,PWM2,,__GET_VAR(data__->WK_HYP0.OUT,));
  };
  __SET_VAR(data__->WK_HYP1.,EN,,__GET_VAR(data__->WKON3,));
  __SET_VAR(data__->WK_HYP1.,H,,__GET_VAR(data__->WKSET3,));
  __SET_VAR(data__->WK_HYP1.,CV,,__GET_VAR(data__->TEMP3,));
  __SET_VAR(data__->WK_HYP1.,L,,__GET_VAR(data__->_TMP_SUB185_OUT,));
  WK_HYP_body__(&data__->WK_HYP1);
  if (__GET_VAR(data__->WK_HYP1.ENO,)) {
    __SET_LOCATED(data__->,PWM3,,__GET_VAR(data__->WK_HYP1.OUT,));
  };
  __SET_VAR(data__->WK_HYP4.,EN,,__GET_VAR(data__->WKON1,));
  __SET_VAR(data__->WK_HYP4.,H,,__GET_VAR(data__->WKSET1,));
  __SET_VAR(data__->WK_HYP4.,CV,,__GET_VAR(data__->TEMP1,));
  __SET_VAR(data__->WK_HYP4.,L,,__GET_VAR(data__->_TMP_SUB215_OUT,));
  WK_HYP_body__(&data__->WK_HYP4);
  if (__GET_VAR(data__->WK_HYP4.ENO,)) {
    __SET_LOCATED(data__->,PWM1,,__GET_VAR(data__->WK_HYP4.OUT,));
  };
  __SET_VAR(data__->WK_PID0.,EN,,__GET_VAR(data__->WKON1,));
  __SET_VAR(data__->WK_PID0.,SV,,__GET_VAR(data__->WKSET1,));
  __SET_VAR(data__->WK_PID0.,CV,,__GET_VAR(data__->TEMP1,));
  __SET_VAR(data__->WK_PID0.,RANGER,,100.0);
  __SET_VAR(data__->WK_PID0.,KP,,__GET_VAR(data__->KP,));
  __SET_VAR(data__->WK_PID0.,KI,,__GET_VAR(data__->KI,));
  __SET_VAR(data__->WK_PID0.,KD,,__GET_VAR(data__->KD,));
  WK_PID_body__(&data__->WK_PID0);
  __SET_VAR(data__->WK_PID1.,EN,,__GET_VAR(data__->WKON2,));
  __SET_VAR(data__->WK_PID1.,SV,,__GET_VAR(data__->WKSET2,));
  __SET_VAR(data__->WK_PID1.,CV,,__GET_VAR(data__->TEMP2,));
  __SET_VAR(data__->WK_PID1.,RANGER,,100.0);
  __SET_VAR(data__->WK_PID1.,KP,,__GET_VAR(data__->KP,));
  __SET_VAR(data__->WK_PID1.,KI,,__GET_VAR(data__->KI,));
  __SET_VAR(data__->WK_PID1.,KD,,__GET_VAR(data__->KD,));
  WK_PID_body__(&data__->WK_PID1);
  __SET_VAR(data__->,_TMP_REAL_TO_UINT31_OUT,,REAL_TO_UINT(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WK_PID0.OUT,)));
  __SET_VAR(data__->,_TMP_REAL_TO_UINT25_OUT,,REAL_TO_UINT(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WK_PID1.OUT,)));
  __SET_VAR(data__->WK_PID2.,EN,,__GET_VAR(data__->WKON3,));
  __SET_VAR(data__->WK_PID2.,SV,,__GET_VAR(data__->WKSET3,));
  __SET_VAR(data__->WK_PID2.,CV,,__GET_VAR(data__->TEMP3,));
  __SET_VAR(data__->WK_PID2.,RANGER,,100.0);
  __SET_VAR(data__->WK_PID2.,KP,,__GET_VAR(data__->KP,));
  __SET_VAR(data__->WK_PID2.,KI,,__GET_VAR(data__->KI,));
  __SET_VAR(data__->WK_PID2.,KD,,__GET_VAR(data__->KD,));
  WK_PID_body__(&data__->WK_PID2);
  __SET_VAR(data__->WK_PID3.,EN,,__GET_VAR(data__->WKON4,));
  __SET_VAR(data__->WK_PID3.,SV,,__GET_VAR(data__->WKSET4,));
  __SET_VAR(data__->WK_PID3.,CV,,__GET_VAR(data__->TEMP4,));
  __SET_VAR(data__->WK_PID3.,RANGER,,100.0);
  __SET_VAR(data__->WK_PID3.,KP,,__GET_VAR(data__->KP,));
  __SET_VAR(data__->WK_PID3.,KI,,__GET_VAR(data__->KI,));
  __SET_VAR(data__->WK_PID3.,KD,,__GET_VAR(data__->KD,));
  WK_PID_body__(&data__->WK_PID3);
  __SET_VAR(data__->,_TMP_REAL_TO_UINT63_OUT,,REAL_TO_UINT(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WK_PID2.OUT,)));
  __SET_VAR(data__->,_TMP_REAL_TO_UINT96_OUT,,REAL_TO_UINT(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WK_PID3.OUT,)));
  __SET_VAR(data__->,_TMP_SUB200_OUT,,SUB__REAL__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WKSET4,),
    (REAL)__GET_VAR(data__->WKSET_L,)));
  __SET_VAR(data__->,_TMP_SUB185_OUT,,SUB__REAL__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WKSET3,),
    (REAL)__GET_VAR(data__->WKSET_L,)));
  __SET_VAR(data__->,_TMP_SUB215_OUT,,SUB__REAL__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WKSET1,),
    (REAL)__GET_VAR(data__->WKSET_L,)));
  __SET_VAR(data__->,_TMP_SUB177_OUT,,SUB__REAL__REAL__REAL(
    (BOOL)__BOOL_LITERAL(TRUE),
    NULL,
    (REAL)__GET_VAR(data__->WKSET2,),
    (REAL)__GET_VAR(data__->WKSET_L,)));

  goto __end;

__end:
  return;
} // PROGRAM0_body__() 





void PROGRAM0_Input(PROGRAM0 *data__){
__SET_LOCATED(data__->,TEMP_IN1,,fast_input(1,12,0,0,0));
__SET_LOCATED(data__->,TEMP_IN2,,fast_input(1,12,1,0,0));
__SET_LOCATED(data__->,TEMP_IN3,,fast_input(1,12,2,0,0));
__SET_LOCATED(data__->,TEMP_IN4,,fast_input(1,12,3,0,0));
__SET_LOCATED(data__->,LOCALVAR14,,fast_input(1,10,5,0,0));
__SET_LOCATED(data__->,LOCALVAR15,,fast_input(1,10,6,0,0));
__SET_LOCATED(data__->,LOCALVAR16,,fast_input(1,10,7,0,0));
__SET_LOCATED(data__->,LOCALVAR17,,fast_input(1,10,8,0,0));
__SET_LOCATED(data__->,DCMOTOR_SPEED,,fast_input(1,11,14,0,0));
__SET_LOCATED(data__->,X1,,fast_input(1,10,1,0,0));
__SET_LOCATED(data__->,X2,,fast_input(1,10,2,0,0));
__SET_LOCATED(data__->,X3,,fast_input(1,10,3,0,0));
__SET_LOCATED(data__->,X4,,fast_input(1,10,4,0,0));
}
void PROGRAM0_Output(PROGRAM0 *data__){
fast_output(1,10,25,0,0,__GET_LOCATED(data__->DCMOTOR_RUN,));
fast_output(1,10,26,0,0,__GET_LOCATED(data__->DCMOTOR_DIR,));
fast_output(1,11,16,0,0,__GET_LOCATED(data__->DCMOTOR_SPEED_SET,));
fast_output(1,11,15,0,0,__GET_LOCATED(data__->DCMOTOR_FREQ,));
fast_output(1,11,17,0,0,__GET_LOCATED(data__->DC_MOTOR2_SPEED,));
fast_output(1,10,16,0,0,__GET_LOCATED(data__->J1,));
fast_output(1,10,17,0,0,__GET_LOCATED(data__->J2,));
fast_output(1,10,18,0,0,__GET_LOCATED(data__->J3,));
fast_output(1,10,19,0,0,__GET_LOCATED(data__->J4,));
fast_output(1,11,4,0,0,__GET_LOCATED(data__->PWM1,));
fast_output(1,11,5,0,0,__GET_LOCATED(data__->PWM2,));
fast_output(1,11,6,0,0,__GET_LOCATED(data__->PWM3,));
fast_output(1,11,7,0,0,__GET_LOCATED(data__->PWM4,));
}